<?php
/**
 * product_listing module
 *
 * @package modules
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: product_listing.php 18695 2011-05-04 05:24:19Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
$show_submit = zen_run_normal();

$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
$zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);

$row = 0;
$col = 0;
$list_box_contents = array();
define('MAX_DISPLAY_PRODUCTS_PER_ROW',5);
if ($listing_split->number_of_rows > 0) {
  if ($listing_split->number_of_rows < MAX_DISPLAY_PRODUCTS_PER_ROW || MAX_DISPLAY_PRODUCTS_PER_ROW == 0) {
    $col_width = floor(100/$listing_split->number_of_rows);
  } else {
    $col_width = floor(100/MAX_DISPLAY_PRODUCTS_PER_ROW);
  }
  
  $listing = $db->Execute($listing_split->sql_query);
  while (!$listing->EOF) {
	$products_price = $currencies->display_price((zen_get_products_actual_price($listing->fields['products_id'])),0);

    $list_box_contents[$row][$col] = array('params' => 'style="float:left;margin:10px 0;width:' . $col_width . '%;"',
                                           'text' =>'<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '"><img src="'.DIR_WS_IMAGES . $listing->fields['products_image'].'" alt="'.$listing->fields['products_name'].'" width="125px" height="120px" /></a><br />'.
    '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . zen_get_product_path($listing->fields['products_id']). '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a><br /><div class="actual_price" style="text-align:center;">' .$products_price.'</div>'
                                           );

    $col ++;
    if ($col > (MAX_DISPLAY_PRODUCTS_PER_ROW -1)) {
      $col = 0;
      $row ++;
    }
    $listing->MoveNext();
  }
}
$title = false;